﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Imaginecup.gameState.recycling.Sprite;
using Imaginecup.gameState.recycling.Object.UI;

namespace Imaginecup.recycling.Object.Menu
{
    public class Updater
    {
        private static Updater Instance;
        public static Updater GetInstance()
        {
            if(Instance == null)
                Instance = new Updater();
            return Instance;
        }
        private List<IUpdate> AllUpdater;

        private Updater()
        {
            AllUpdater = new List<IUpdate>();
        }

        public void Update(GameTime gameTime)
        {
            foreach (IUpdate sprite in AllUpdater)
            {
                sprite.Update(gameTime);
            }
        }

        public void AddUpdate(IUpdate sprite)
        {
            if(!AllUpdater.Contains(sprite))
                AllUpdater.Add(sprite);
        }
        public void RemoveUpdate(IUpdate sprite)
        {
            if (AllUpdater.Contains(sprite))
                AllUpdater.Remove(sprite);
        }
    }
}
